/**
 * @Author: 陈瑞鹏
 * @Date:   2022-10-14 17:18:19
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2022-10-17 16:48:48
 */
import abiao_utils from 'abiao_utils';
import dotenv from 'dotenv';
import mongoose from 'mongoose';

dotenv.config({ path: '.env' });

mongoose.connect(process.env.DB_HOST + process.env.DB_NAME, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true });

//监听连接成功
mongoose.connection.on('connected', () => {
  console.log(process.env.DB_HOST + process.env.DB_NAME, process.env.ENV, abiao_utils.getIPAdress());
  console.log("mongoose 连接成功!");
})

mongoose.connection.on('error', () => {
  console.log("mongoose 连接错误!");
})

mongoose.connection.on("disconnnected", () => {
  console.log("mongoose 连接断开!");
})